package org.rcgwt.client.ui.calendar.event;

import java.util.Date;
import java.util.List;

import com.google.gwt.event.shared.GwtEvent;

/**
 * A SelectionChanged event that provides a list of selected dates to the user
 * 
 * @author Elian ORIOU
 * 
 */

public class SelectionChangedEvent extends GwtEvent<SelectionChangedHandler> {

	private final List<Date> dates;
	private static final GwtEvent.Type<SelectionChangedHandler> TYPE = new GwtEvent.Type<SelectionChangedHandler>();

	public SelectionChangedEvent(List<Date> dates) {
		this.dates = dates;
	}

	public List<Date> getDates() {
		return dates;
	}

	@Override
	protected void dispatch(SelectionChangedHandler handler) {
		handler.onSelectionChanged(this);
	}

	public static void fire(HasSelectionChangedHandlers source, List<Date> d) {
		if (TYPE != null) {
			SelectionChangedEvent event = new SelectionChangedEvent(d);
			source.fireEvent(event);
		}
	}

	@Override
	public com.google.gwt.event.shared.GwtEvent.Type<SelectionChangedHandler> getAssociatedType() {
		return TYPE;
	}

	public static GwtEvent.Type<SelectionChangedHandler> getType() {
		return TYPE;
	}
}
